
public class Coord {
	int x;
	int y;
	private Box myBox = null;
	
	public Coord(int x, int y) {
		this.x=x;
		this.y=y;		
	}
	
	public Coord(Coord c) {
		this.x=c.x;
		this.y=c.y;		
	}
	
	public void setValue(int x, int y) {
		this.x=x;
		this.y=y;
	}
	
	public void setValue(Coord c) {
		this.x=c.x;
		this.y=c.y;
	}
	
	public boolean isItSameCoord(int x, int y) {
		return ((this.x==x)&&(this.y==y));
	}
	
	public boolean isItSameCoord(Coord c) {
		return ((this.x==c.x)&&(this.y==c.y));
	}
	
	public Coord getSouthCoord() {
		return new Coord(x, y+1);
	}
	
	public Coord getNorthCoord() {
		return new Coord(x, y-1);
	}
	
	public Coord getWestCoord() {
		return new Coord(x-1, y);
	}
	
	public Coord getEastCoord() {
		return new Coord(x+1, y);
	}
	
	public void setToSouthCoord() {
		this.y=this.y+1;
	}
	
	public void setToNorthCoord() {
		this.y=this.y-1;
	}
	
	public void setToWestCoord() {
		this.x=this.x-1;
	}
	
	public void setToEastCoord() {
		this.x=this.x+1;
	}
	
	public void setMyBox(Box myBox) {
		this.myBox = myBox;
	}
	
	public Box getMyBox() {
		return myBox;
	}
	
	public void print() {
		System.out.println("(" + x + ", " + y + ")");
	}
	
	/**
	 * Retrieve the Coord that you would get if you started at the given Coord and took one step in the given Direction
	 * @param c A Coord
	 * @param direction A Direction, u,r,d,l
	 * @return A new Coord
	 */
	public Coord getCoordFromDirection(char direction) {
		switch(direction) {
		case 'u':   
		case 'U':   return getNorthCoord();		
		case 'r':   
		case 'R':   return getEastCoord();		 
		case 'd':   
		case 'D':   return getSouthCoord();		
		case 'l':   
		case 'L':   return getWestCoord();	
		default:  System.out.println("Non-legal instruction");   break;
		}
		return null;
	}
	
	public Coord setCoordFromDirection(char direction) {
		switch(direction) {
		case 'd':   
		case 'D':   setToNorthCoord();		break;
		case 'l':   
		case 'L':   setToEastCoord();		break; 
		case 'u':   
		case 'U':   setToSouthCoord();		break;
		case 'r':   
		case 'R':   setToWestCoord();		break;
		default:  System.out.println("Non-legal instruction");   break;
		}
		return null;
	}
	
	
	public Coord getCoordFromDirectionRev(char direction) {
		switch(direction) {
		case 'd':   
		case 'D':   return getNorthCoord();		
		case 'l':   
		case 'L':   return getEastCoord();		 
		case 'u':   
		case 'U':   return getSouthCoord();		
		case 'r':   
		case 'R':   return getWestCoord();	
		default:  System.out.println("Non-legal instruction");   break;
		}
		return null;
	}
}
